/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sellcar;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author Fabio Valenzuela
 */
public class Cadastro_ClienteDAO {
    
        private Connection connection;

    public Cadastro_ClienteDAO() {
        this.connection = new ConnectionFactory().getConnection();
    }
    public void adiciona (Cliente cliente){
        String sql = "insert into tb_cadastro_cliente" + "(nome_cliente,data_nasc,cpf,rg,data_emissao,orgao_emissor,naturalidade,nome_mae,nome_pai,endereco,numero,complemento,bairro,cep,cidade,estado,telefone,celular,empresa,cargo,tempo_empresa,end_empresa,complemento_empresa,bairro_empresa,cidade_empresa,estado_empresa,telefone_empresa,salario,agencia,conta,banco,email)" + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        try{
            PreparedStatement stmt = connection.prepareStatement(sql);
            
            stmt.setString(1, cliente.getNome());
            stmt.setString(2, cliente.getDt_nasc());
            //stmt.setLong(3, cliente.getCpf());
            stmt.setString(3, cliente.getCpf());
            stmt.setString(4, cliente.getRg());
            stmt.setString(5, cliente.getDt_emissao());
            stmt.setString(6, cliente.getOrgao());
            stmt.setString(7, cliente.getNaturalidade());
            stmt.setString(8, cliente.getMae());
            stmt.setString(9, cliente.getPai());
            stmt.setString(10, cliente.getEnd());
            stmt.setString(11, cliente.getNum());
            stmt.setString(12, cliente.getCompl());
            stmt.setString(13, cliente.getBairro());
            stmt.setString(14, cliente.getCep());
            stmt.setString(15, cliente.getCidade());
            stmt.setString(16, cliente.getUf());
            stmt.setString(17, cliente.getTel());
            stmt.setString(18, cliente.getCel());
            stmt.setString(19, cliente.getEmpresa());
            stmt.setString(20, cliente.getCargo());
            stmt.setString(21, cliente.getTemp_empresa());
            stmt.setString(22, cliente.getEnd2());
            stmt.setString(23, cliente.getCompl2());
            stmt.setString(24, cliente.getBairro2());
            stmt.setString(25, cliente.getCidade2());
            stmt.setString(26, cliente.getUf());
            stmt.setString(27, cliente.getTel2());
            stmt.setString(28, cliente.getSalario());
            stmt.setString(29, cliente.getAgencia());
            stmt.setString(30, cliente.getConta());
            stmt.setString(31, cliente.getBanco());
            stmt.setString(32, cliente.getEmail());
            
            stmt.execute();
            stmt.close();
            connection.close();
        }catch(SQLException e ){
            throw new RuntimeException(e);
        }
    }

        
}
